package cn.iocoder.yudao.module.contract.service.invoice;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.module.contract.dal.dataobject.client.ClientDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.company.CompanyDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.contractTemplate.ContractTemplateDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDetailsDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceOrdersDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.invoiceContract.InvoiceContractDO;
import cn.iocoder.yudao.module.contract.dal.mysql.invoice.InvoiceDetailsMapper;
import cn.iocoder.yudao.module.contract.dal.mysql.invoice.InvoiceOrdersMapper;
import cn.iocoder.yudao.module.contract.service.client.ClientService;
import cn.iocoder.yudao.module.contract.service.company.CompanyService;
import cn.iocoder.yudao.module.contract.service.contractTemplate.ContractTemplateService;
import cn.iocoder.yudao.module.contract.service.invoiceContract.InvoiceContractService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.omg.CORBA.DynAnyPackage.Invalid;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

import cn.iocoder.yudao.module.contract.controller.admin.invoice.vo.*;
import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.contract.dal.mysql.invoice.InvoiceMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.contract.enums.ErrorCodeConstants.*;
import static org.hibernate.validator.internal.util.Contracts.assertNotNull;

/**
 * 发票 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
@Slf4j
public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, InvoiceDO> implements InvoiceService {

    @Resource
    private InvoiceMapper invoiceMapper;
    @Resource
    private InvoiceDetailsMapper invoiceDetailsMapper;
    @Resource
    private InvoiceOrdersService invoiceOrdersService;
    @Resource
    private ClientService clientService;
    @Resource
    private InvoiceOrdersMapper invoiceOrdersMapper;
    @Resource
    private ContractTemplateService templateService;
    @Resource
    private CompanyService companyService;
    @Resource
    private InvoiceContractService invoiceContractService;

    @Value("${baiwang.invoice.url}")
    private String invoiceUrl;

    @Override
    public InvoiceDO getInvoice(Long id) {
        return invoiceMapper.selectById(id);
    }

    @Override
    public PageResult<InvoicePageRespVO> getInvoicePage(InvoicePageReqVO pageReqVO) {
        return invoiceMapper.selectPage(pageReqVO);
    }

    // ==================== 子表（发票明细） ====================

    @Override
    public PageResult<InvoiceDetailsDO> getInvoiceDetailsPage(PageParam pageReqVO, String zskpId) {
        return invoiceDetailsMapper.selectPage(pageReqVO, zskpId);
    }


    @Override
    public InvoiceDetailsDO getInvoiceDetails(Long id) {
        return invoiceDetailsMapper.selectById(id);
    }

    private void validateInvoiceDetailsExists(Long id) {
        if (invoiceDetailsMapper.selectById(id) == null) {
            throw exception(INVOICE_DETAILS_NOT_EXISTS);
        }
    }

    private void deleteInvoiceDetailsByInvoiceId(Long invoiceId) {
        invoiceDetailsMapper.deleteByInvoiceId(invoiceId);
    }

    // ==================== 子表（发票订单信息） ====================

    @Override
    public PageResult<InvoiceOrdersDO> getInvoiceOrdersPage(PageParam pageReqVO, String ddSqkpRecordId) {
        return invoiceOrdersMapper.selectPage(pageReqVO, ddSqkpRecordId);
    }

    @Override
    public InvoiceOrdersDO getInvoiceOrders(Long id) {
        return invoiceOrdersMapper.selectById(id);
    }

    @Override
    public String invoiceSync(String startDate, String endDate) {
        log.info("发票同步调用开始,startDate：{}，endDate：{}",startDate,endDate);
        int total = 0;
        int add=0;
        int error=0;
        try {
            HashMap<String, Object> paramMap = new HashMap<>();
            paramMap.put("kprqq", startDate);
            paramMap.put("kprqz", endDate);

            String result= HttpUtil.post(invoiceUrl+"/getinvoiceinfo", paramMap);
            JSONObject jsonObject = JSONObject.parseObject(result);
            if(jsonObject == null && jsonObject.get("data")==null){
                throw exception("发票同步返回数据异常");
            }
            JSONArray data = jsonObject.getJSONArray("data");
            total = data.size();
            if(total>0){
                List<InvoiceDO> invoiceList = new ArrayList<>();
                invoiceList = BeanUtils.toBean(data,InvoiceDO.class);
                for(InvoiceDO invoice : invoiceList){
                    if(StringUtils.isNotBlank(invoice.getCoustomerid())){
                        invoice.setClientCode(invoice.getCoustomerid().substring(3));
                    }
                    invoice.setUpdateTime(LocalDateTime.now());
                    invoice.setStatus("-2");
                    if(StringUtils.isBlank(invoice.getYfphm())){
                        if("04".equals(invoice.getZzhtgklx()) || "05".equals(invoice.getZzhtgklx())){
                            invoice.setStatus("0");
                        }
                    }else{
                        invoice.setStatus("-1");
                    }
    //                try{
    //                    JSONObject item = data.getJSONObject(i);
    //                    InvoiceDO invoiceDO = BeanUtils.toBean(item,InvoiceDO.class);
    ////                    long count = invoiceMapper.selectCount(new LambdaQueryWrapper<InvoiceDO>().eq(InvoiceDO::getZskpId,invoiceDO.getZskpId()));
    ////                    if(count>0){
    ////                        continue;
    ////                    }
    //                    if(StringUtils.isNotBlank(invoiceDO.getKprq())){
    //                        Date invoiceDate = DateUtil.parseDateTime(invoiceDO.getKprq());
    //                        invoiceDO.setInvoiceMonth(DateUtil.format(invoiceDate,"yyyy-MM"));
    //                    }
    //                    invoiceList.add(invoiceDO);
    ////                    save(invoiceDO);
    //                    add = add+1;
    //                }catch (Exception e){
    //                    error = error+1;
    //                    log.error("发票同步数据添加异常",e);
    //                }
                }
                invoiceMapper.batchInsertInvoices(invoiceList);
                List<InvoiceDetailsDO> invoiceDetails = new ArrayList<>();

                for(InvoiceDO invoice : invoiceList){
                    if(StringUtils.isNotBlank(invoice.getInvoiceMxInfos())){
                        JSONArray infos = JSONArray.parseArray(invoice.getInvoiceMxInfos());
                        if(infos.size()>0){
                            List<InvoiceDetailsDO> details = BeanUtils.toBean(infos,InvoiceDetailsDO.class);
                            details.forEach(detail -> detail.setZskpId(invoice.getZskpId()));
                            invoiceDetails.addAll(details);
                        }
                    }
                }
                if(invoiceDetails.size()>0){
                    invoiceDetailsMapper.batchInsertDetails(invoiceDetails);

                }

            }
            invoiceOrderSync(startDate,endDate);
            invoiceDataAssert(startDate,endDate);
            updateInvalidInvoice();

            log.info("发票同步调用结束");
            return StrUtil.format("同步成功-共{}条。",total);
        }
        catch (Exception e) {
            log.error("发票同步调用异常",e);
            return StrUtil.format("同步失败-{}",e.getMessage());
        }
    }

    /**
     *
     * @param generateContractVO
     * @return
     */
    @Override
    public String generateContract(GenerateContractVO generateContractVO) {
        String operateType = generateContractVO.getOperateType();
        //发票数据
        List<InvoiceDO> list = null;
        //借贷项发票
        List<InvoiceDO> list1 = new ArrayList<>();
        String signingDate = "";
        if("1".equals(generateContractVO.getType())) {
            //手动生成
            list = list(Wrappers.<InvoiceDO>lambdaQuery().in(InvoiceDO::getId,Arrays.asList(generateContractVO.getIds().split(","))).in(InvoiceDO::getStatus, Arrays.asList("0,2".split(","))).ne(InvoiceDO::getVsbed,"").isNotNull(InvoiceDO::getVsbed));
            list1 = list(Wrappers.<InvoiceDO>lambdaQuery().in(InvoiceDO::getId,Arrays.asList(generateContractVO.getIds().split(","))).in(InvoiceDO::getStatus, Arrays.asList("0,2".split(","))).and(i->i.eq(InvoiceDO::getVsbed,"").or().isNull(InvoiceDO::getVsbed)));

            if(StringUtils.isNotBlank(generateContractVO.getSigningDate())){
                signingDate = generateContractVO.getSigningDate();
            }
        }else if("2".equals(generateContractVO.getType())) {
            //批量生成
            list = list(Wrappers.<InvoiceDO>lambdaQuery().in(InvoiceDO::getId,Arrays.asList(generateContractVO.getIds().split(","))).in(InvoiceDO::getStatus,Arrays.asList("0,2".split(","))));
        }else if("3".equals(generateContractVO.getType())) {
            //退货批量生成
            list = list(Wrappers.<InvoiceDO>lambdaQuery().in(InvoiceDO::getId,Arrays.asList(generateContractVO.getIds().split(","))).in(InvoiceDO::getStatus,Arrays.asList("0,2".split(","))).le(InvoiceDO::getJshj,"0"));
        }
        if(list ==null || list.size()==0) {
            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"无可生成合同的发票数据");
        }
        Map<String, List<InvoiceDO>> invoicesMap = list.stream().collect(Collectors.groupingBy(item -> item.getXfmc() + "-" + item.getGfmc()+ "-" +item.getVsbed()));
        Map<String, List<InvoiceDO>> invoicesMap1 = list1.stream().collect(Collectors.groupingBy(item -> item.getXfmc() + "-" + item.getGfmc()));
        if("1".equals(generateContractVO.getType()) && invoicesMap.size()>1){
            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"请选择售达方、公司主体、运输方式一致的发票数据");
        }
        for (String key : invoicesMap.keySet()) {
            if(!"1".equals(generateContractVO.getType())) {
                signingDate = "";
            }
            List<InvoiceDO> invoiceList = invoicesMap.get(key);
            if("1".equals(generateContractVO.getType())){
                String xfmcGfmcKey = key.substring(0, key.lastIndexOf("-"));
                List<InvoiceDO> invoiceList1 = invoicesMap1.get(xfmcGfmcKey);
                if(invoiceList1!=null && invoiceList1.size()>0){
                    invoiceList.addAll(invoiceList1);
                }
            }
            if(invoiceList.size()>0){
                InvoiceDO maxInvoice = invoiceList.stream().max(Comparator.comparing(InvoiceDO::getKprq)).get();
                InvoiceDO minInvoice = invoiceList.stream().min(Comparator.comparing(InvoiceDO::getKprq)).get();
                InvoiceDO minInvoice1 = invoiceList.stream().filter(invoice -> StringUtils.isNotBlank(invoice.getVsbed())).min(Comparator.comparing(InvoiceDO::getKprq)).orElse(null);
                if(minInvoice1 ==null){
                    minInvoice1 = new InvoiceDO();
                }
                CompanyDO company = companyService.getOne(Wrappers.<CompanyDO>lambdaQuery().eq(CompanyDO::getCompanyName,maxInvoice.getGfmc()));

                List<Long> invoiceIds = invoiceList.stream().map(InvoiceDO::getId).collect(Collectors.toList());
                if(!"3".equals(generateContractVO.getType())){
                    List<String> zskpIds = invoiceList.stream().map(InvoiceDO::getZskpId).collect(Collectors.toList());
                    List<Map<String,Object>> detailsSumList = invoiceDetailsMapper.selectMaps(Wrappers.<InvoiceDetailsDO>query().select("ggxh, hsdj ,sum(hsje) as hsjeTotal ,sum(sl) as slTotal").ne("sl","").in("zskp_id",zskpIds).groupBy("ggxh","hsdj").having("SUM(hsje) <= 0 or SUM(sl) <= 0"));
                    if(detailsSumList.size()>0){
                        log.info("明细数据存在金额或数量统计为负数：，{}",JSONObject.toJSONString(detailsSumList));
                        if("1".equals(generateContractVO.getType())){
                            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"明细数据存在金额或数量统计为负数");
                        }else{
                            continue;
                        }
                    }
                }
                BigDecimal totalMoney = invoiceList.stream().filter(map -> map.getJshj() != null).map(map -> {return new BigDecimal(map.getJshj());}).reduce(BigDecimal.ZERO, BigDecimal::add);
                InvoiceContractDO invoiceContract = new InvoiceContractDO();
                invoiceContract.setGenerationType("1".equals(generateContractVO.getType())?"1":"2");
                invoiceContract.setClientCode(minInvoice.getClientCode());
                invoiceContract.setGfmc(minInvoice.getGfmc());
                invoiceContract.setCompanyid(minInvoice.getCompanyid());
                invoiceContract.setXfmc(minInvoice.getXfmc());
                if(company!=null){
                    //公司间签订日期：最早的开票月份的一号
                    invoiceContract.setContractType("1");
//                    invoiceContract.setSigningDate((minInvoice.getInvoiceMonth()+"-01"));
                    if(StringUtils.isBlank(signingDate)){
                        signingDate = minInvoice.getInvoiceMonth()+"-01";
                    }
                    invoiceContract.setSigningDate(signingDate);
                }else{
                    if("3".equals(generateContractVO.getType())) {
                        //退货协议订日期：最早的发货单过账日期
                        List<String> ddSqkpRecordIds = invoiceList.stream().map(InvoiceDO::getDdSqkpRecordId).collect(Collectors.toList());
                        InvoiceOrdersDO invoiceOrders = invoiceOrdersService.getOne(Wrappers.<InvoiceOrdersDO>lambdaQuery().in(InvoiceOrdersDO::getDdSqkpRecordId,ddSqkpRecordIds).orderByAsc(InvoiceOrdersDO::getWadatLst),false);
                        if(invoiceOrders==null){
                            continue;
                        }
                        invoiceContract.setSigningDate(DateUtil.format(invoiceOrders.getWadatLst(),"yyyy-MM-dd"));
                        invoiceContract.setContractType("4");
                    }else{
                        //其他：最早的开票日期
                        invoiceContract.setContractType("2");
//                        invoiceContract.setSigningDate(DateUtil.formatDate(DateUtil.parseDateTime(minInvoice.getKprq())));
                        if(StringUtils.isBlank(signingDate)){
                            signingDate = DateUtil.formatDate(DateUtil.parseDateTime(minInvoice.getKprq()));
                        }
                        invoiceContract.setSigningDate(signingDate);
                    }
                }
                invoiceContract.setInvoiceMonth(minInvoice.getInvoiceMonth());
                invoiceContract.setTotalMoney(totalMoney.toString());
                invoiceContract.setVsbed(StringUtils.isNotBlank(minInvoice.getVsbed())?minInvoice.getVsbed():minInvoice1.getVsbed());
                invoiceContract.setVsbedms(StringUtils.isNotBlank(minInvoice.getVsbedms())?minInvoice.getVsbedms():minInvoice1.getVsbedms());
                invoiceContract.setZzhtgklx(StringUtils.isNotBlank(minInvoice.getZzhtgklx())?minInvoice.getZzhtgklx():minInvoice1.getZzhtgklx());
                invoiceContract.setZzhtgklxms(StringUtils.isNotBlank(minInvoice.getZzhtgklxms())?minInvoice.getZzhtgklxms():minInvoice1.getZzhtgklxms());
                invoiceContract.setSellertaxid(minInvoice.getSellertaxid());
                invoiceContract.setSellertaxname(minInvoice.getSellertaxname());
                invoiceContract.setSalesmethodname(minInvoice.getSalesmethodname());
                invoiceContract.setQyusername(minInvoice.getQyusername());
                invoiceContract.setDdh(minInvoice.getDdh());
                invoiceContract.setInvoiceIds(invoiceIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
                invoiceContract.setGeneratedTime(LocalDateTime.now());
                invoiceContract.setStatus("0");
                if("1".equals(operateType)){
                    invoiceContractService.save(invoiceContract);
                }
                invoiceContractService.generateContractFile(invoiceContract,invoiceList,operateType);
                if("1".equals(operateType)){
                    invoiceContractService.updateById(invoiceContract);
                    for(InvoiceDO invoice : invoiceList){
                        InvoiceDO invoiceDO = new InvoiceDO();
                        invoiceDO.setId(invoice.getId());
                        invoiceDO.setStatus("1");
                        invoiceDO.setContractNo(invoiceContract.getContractNo());
                        invoiceDO.setContractId(invoiceContract.getId());
                        invoiceDO.setContractGeneratedTime(LocalDateTime.now());
                        updateById(invoiceDO);
                    }
                    invoiceStatusPush(invoiceList,"1");
                }else{
                    return invoiceContract.getContractHtml();
                }
            }
        }


        return null;
    }

    /**
     * 发票数据维护-补充非接口的字段
     * @param startDate
     * @param endDate
     */
    private void invoiceDataAssert(String startDate, String endDate) {
        try {
            List<InvoiceDO> list = list(new LambdaQueryWrapper<InvoiceDO>().ge(InvoiceDO::getKprq, startDate).le(InvoiceDO::getKprq, endDate));
            List<InvoiceDO> updateList = new ArrayList();
            for (InvoiceDO invoice : list) {
                int isUpdate = 0;
                if (StringUtils.isBlank(invoice.getDdh()) || ObjectUtil.isEmpty(invoice.getAudat())) {
                    //过滤借贷项“贷项凭单请求-ZCR”或“借项凭证请求-ZDR”
                    LambdaQueryWrapper<InvoiceOrdersDO> queryWrapper = new LambdaQueryWrapper();
                    queryWrapper.orderByAsc(InvoiceOrdersDO::getAudat);
                    queryWrapper.eq(InvoiceOrdersDO::getZskpId, invoice.getZskpId());
                    queryWrapper.ne(InvoiceOrdersDO::getAuart,"ZCR");
                    queryWrapper.ne(InvoiceOrdersDO::getAuart,"ZDR");
                    InvoiceOrdersDO orders = invoiceOrdersService.getOne(queryWrapper, false);
                    if (orders != null) {
                        invoice.setDdh(orders.getDdh());
                        invoice.setAudat(orders.getAudat());
                        isUpdate=1;
                    }
                }

                if(StringUtils.isBlank(invoice.getInvoiceMonth()) && StringUtils.isNotBlank(invoice.getKprq())){
                    Date invoiceDate = DateUtil.parseDateTime(invoice.getKprq());
                    invoice.setInvoiceMonth(DateUtil.format(invoiceDate,"yyyy-MM"));
                    isUpdate=1;
                }
                if(StringUtils.isBlank(invoice.getClientCode())  && StringUtils.isNotBlank(invoice.getGfmc()) ){
                    ClientDO client = clientService.getClientByName(invoice.getGfmc());
                    if(client!=null){
                        invoice.setClientCode(client.getClientCode());
                    }
                }
                if(isUpdate==1){
                    updateList.add(invoice);
                }
            }
            if(updateList.size()>0){
                updateBatchById(updateList);
            }
        }catch (Exception e) {
            log.error("发票数据维护-补充非接口的字段",e);
        }
    }

    private void updateInvalidInvoice(){
        int count = invoiceMapper.updateInvalidInvoice();
        log.info("修改无效发票数量:{}",count);
    }

    public String invoiceStatusPush(List<InvoiceDO> invoiceList,String status){
        try{
            if(invoiceList.size()==0){
                return "";
            }
            JSONObject param = new JSONObject();
            JSONArray jsonArray = new JSONArray();
            for(InvoiceDO invoiceDO : invoiceList){
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("fphm",invoiceDO.getFphm());
                jsonObject.put("htzt",status);
                jsonArray.add(jsonObject);
            }
            param.put("data",jsonArray);
            log.info("通知百旺合同状态开始:{}",param);
            String result = HttpUtil.post(invoiceUrl+"/getddinfo", param);
            log.info("通知百旺合同状态结束:{}",result);
            return result;
        }catch (Exception e){
            log.error("通知百旺合同状态异常",e);
            return null;
        }
    }

    /**
     * 发票订单同步
     * @param startDate
     * @param endDate
     */
    public void invoiceOrderSync(String startDate, String endDate) {
        log.info("发票订单同步调用开始,startDate：{}，endDate：{}",startDate,endDate);
        int total = 0;
        int add=0;
        int error=0;
        try {
            HashMap<String, Object> paramMap = new HashMap<>();
            paramMap.put("kprqq", startDate);
            paramMap.put("kprqz", endDate);

            String result= HttpUtil.post(invoiceUrl+"/getddinfo", paramMap);
            JSONObject jsonObject = JSONObject.parseObject(result);
            if(jsonObject == null && jsonObject.get("data")==null){
                throw exception("发票订单同步返回数据异常");
            }
            JSONArray data = jsonObject.getJSONArray("data");
            total = data.size();
            if(total>0){
                List<InvoiceOrdersDO> invoiceOrdersList = new ArrayList<>();
                invoiceOrdersList = BeanUtils.toBean(data,InvoiceOrdersDO.class);
    //            for(int i=0;i<data.size();i++){
    //                try{
    //                    JSONObject item = data.getJSONObject(i);
    //                    InvoiceOrdersDO invoiceOrdersDO = BeanUtils.toBean(item,InvoiceOrdersDO.class);
    //                    long count = invoiceOrdersMapper.selectCount(new LambdaQueryWrapper<InvoiceOrdersDO>().eq(InvoiceOrdersDO::getDdSqkpMxlistId,invoiceOrdersDO.getDdSqkpMxlistId()));
    //                    if(count>0){
    //                        continue;
    //                    }
    //                    invoiceOrdersList.add(invoiceOrdersDO);
    ////                    invoiceOrdersMapper.insert(invoiceOrdersDO);
    //                    add = add+1;
    //                }catch (Exception e){
    //                    error = error+1;
    //                    log.error("发票订单同步数据添加异常",e);
    //                }
    //            }
                if(invoiceOrdersList.size()>0){
                    invoiceOrdersMapper.batchInsertOrders(invoiceOrdersList);
                }
            }
            log.info("发票订单同步调用结束");
            log.info("同步成功-共{}条,新增{}条,失败{}条。",total,add,error);
        }
        catch (Exception e) {
            log.error("发票订单同步调用异常",e);
        }
    }

    private void validateInvoiceOrdersExists(Long id) {
        if (invoiceOrdersMapper.selectById(id) == null) {
            throw exception(INVOICE_ORDERS_NOT_EXISTS);
        }
    }

    private void deleteInvoiceOrdersByZskpId(String zskpId) {
        invoiceOrdersMapper.deleteByZskpId(zskpId);
    }

}